<template>
	<view class="order_detile">
		<!-- #ifdef APP-PLUS -->
		<top-set backgroundColor="#3595f9"></top-set>
		<tab-top fixed="true" title='订单详情' color="#fff" bgColor='#3595f9' after='true' imgSrc='/static/icon/white-back.png'></tab-top>
		<!-- #endif -->
		<order-modular v-if="info" :d="info"></order-modular>
		<service-information v-if="info" @changePage="update" :options="info.hotel_info"></service-information>
		<view class="line"></view>
	</view>
</template>

<script>
	import moment from "moment"
	import orderModular from '@/components/cleaner/order/order-details.vue';
	import serviceInformation from '@/components/cleaner/order/service-information.vue';
	
	export default{
		data() {
			return {
				info:'',
				id:''
			}
		},
		onLoad(e){
			this.id = e.id
			this.initialization(this.id);
		},
		onShow(){
			// #ifdef APP-PLUS
				/**
				 * 启动时,状态栏变亮
				 */
			setTimeout(()=>{
				plus.navigator.setStatusBarStyle('light');
			},150);
				 
			// #endif
		},
		onUnload(){
			// #ifdef APP-PLUS
				/**
				 * 页面关闭时,状态栏变暗
				 */
				plus.navigator.setStatusBarStyle('dark');
			// #endif
		},
		methods: {
			/**
			 * 获取订单数据
			 */
			getOrderData(orderId){
				return new Promise((res)=>{
					this.req({
						url:'both/Order',
						id:orderId,
						method:'get'
					},(data)=>{
						res(data);
					})
				});
			},
			/**
			 * 页面初始化
			 */
			async initialization(orderId){
				let res = await this.getOrderData(orderId);
				this.info = res.data.data;
				this.info.order.create_time = this.dateFil(this.info.order.create_time);
				this.info.order.subscribe_time = this.info.order.subscribe_time?this.dateFil(this.info.order.subscribe_time):'';
				// subscribe_time   订单创建时间   (待接单)
				// create_time     接单时间       (待打扫)
				// arrive_time     保洁到店时间    (待打扫)
				// clean_time     保洁完成时间    (待确认)
				// finish_time     订单完成时间    (已完成)
				if(!this.info.order_status){
					return;
				}
				this.info.order_status.create_time = this.info.order_status.create_time?this.dateFil(this.info.order_status.create_time):'';
				this.info.order_status.finish_time = this.info.order_status.finish_time? this.dateFil(this.info.order_status.finish_time):'';
				this.info.order_status.clean_time = this.info.order_status.clean_time? this.dateFil(this.info.order_status.clean_time):'';
				this.info.order_status.arrive_time = this.info.order_status.arrive_time?this.dateFil(this.info.order_status.arrive_time):'';
				
 			},
			dateFil(val){
				return moment( val*1000 ).format('YYYY-MM-DD HH:mm');
			},
			update(){
				this.initialization(this.id);
			},
			
		},
		mounted(){
			
		},
		computed:{
			
		},
		components: {
			orderModular,
			serviceInformation
		}
	}
</script>

<style>
	page{
		background: #F8F8F8;
	}
	.line{
		width: 100%;
		height: 100upx;
		background-color:#F8F8F8;
		/* background-color:#F8F8F8; */
	}
</style>
